﻿Public Class FileIdMessage
    Inherits MessageBase

    Public Property Type As Byte
    Public Property Manufactourer As Integer
    Public Property Product As Integer
    Public Property SerialNumber As UInt32
    Public Property TimeCreated As Date
    Public Property Number As Integer

    Protected Overrides Sub Populate(reader As System.IO.BinaryReader, Definition As DefinitionMessage)
        For Each FieldDef As FieldDefinition In Definition.Fields
            Dim size As Integer = FieldDef.Size
            Dim FieldDefNumber As Integer = FieldDef.FieldDefinitionNumber
            Dim FieldType As Integer = FieldDef.BaseType

            Select Case FieldDef.FieldDefinitionNumber
                Case 0 'Type
                    Type = reader.ReadByte
                Case 1 'Manufacturer
                    Manufactourer = reader.ReadUInt16
                Case 2 'Product
                    Product = reader.ReadUInt16
                Case 3 'Serial Number
                    SerialNumber = reader.ReadUInt32
                Case 4 'Time created
                    TimeCreated = FitHelper.TranslateDateTime(reader.ReadUInt32)
                Case 5 'Number (?)
                    Number = reader.ReadUInt16
                Case Else
                    FitHelper.ReadUnknownField(reader, FieldDef)
            End Select
        Next
    End Sub
End Class
